var Models = require('./models');
//var Member = require('./models/member.js');
var Workspace = require('./models/workspace.js');
var mongoose = require('mongoose');
var Member = mongoose.model('Member');
var MemberProxy = require('./proxy/member.js');
var config = require('./config.json');
var db = require('./database.js');
var EventProxy = require('eventproxy');
var request = require('request');
var Project = mongoose.model('Project');
var fs = require('fs');
var xml2js = require('xml2js');
var X2JPaser = new xml2js.Parser();
var builder = new xml2js.Builder();
var logger = require('log4js').getLogger();
var space_xml = './space.xml';
var error_data = './error.json';
var correct_data = './correct.json';

logger.info("_______________________________start___________________________________________________");
function exec() {
    var ep = new EventProxy();
    if (config.db) {
        var connection = db.open(config.db);
    }

    Project.find({},function(err,projects){
        if(err){
            console.error(err);
            return false;
        }else{
            ep.after("completed",projects.length, function(){
                logger.info("______________________________________END___________________________________");
            });
            projects.map(function(project){
                Workspace.find({project_id:project._id},function(err,workspaces){
                    if(workspaces.length == 0){
                        logger.info(project.namespace + '/' + project.name);
                    }
                })

            });

        }
    })

}
exec();

